/*=============================================================================

MOTION CONTROL FUNCTION TABLE DEFINITION

FILE: MOTFTbl.h

DESCRIPTION

Motion Control API

EXTERNALIZED FUNCTIONS


Copyright (c) DaeSung Engineering Inc. All rights reserved.

=============================================================================*/
/*=============================================================================

EDIT HISTORY

---------  -------  -------------------------------------------------------
when       who       what, where, why
---------  -------  -------------------------------------------------------
07/15/04   nso4th    Initial version

=============================================================================*/

#ifndef _MOTFUNCTBL_H_
#define _MOTFUNCTBL_H_

/*=============================================================================
HEADER INCLUSION
=============================================================================*/
#include <mxBase.h>

/*---------------------------------------------------------
AUXILIARY
--------------------------------------------------------*/
#include <MOTFTbl_aux.h>

/*=============================================================================
CONSTANT DEFINITION
=============================================================================*/

/*=============================================================================
ENUMERATOR DEFINITION
=============================================================================*/

/*=============================================================================
MOTFTbl CLASS DEFINITION - CUSTOM DEPEND
=============================================================================*/
class MOTFTbl : public MOTFuncTblBase
{
public:
	MOTFTbl();

public:
	virtual boolean Init(void);
	virtual boolean Close(void);

	// Signal
	virtual boolean SigGet(int32 axID, dword dwSig, boolean *pOn);

	virtual boolean SigLevelSet(int32 axID, dword dwSig, boolean bLevel);
	virtual boolean SigLevelGet(int32 axID, dword dwSig, boolean *pLevel);

	// Home
	virtual boolean HomeStop(int32 axID);

	// MoveDone
	virtual boolean MoveDone(int32 axID,boolean *pDone);

	// Position, Velocity & Acceleration
	virtual boolean PosActSet(int32 axID, double64 dPos);
	virtual boolean PosCmdSet(int32 axID, double64 dPos);

	// Software Limit
	boolean SWLimitSet(int32 axID, double64 negPos, double64 posPos);
	boolean SWLimitGet(int32 axID, double64 *negPos, double64 *posPos);


	// Digital I/O
	virtual boolean UserOutput(int32 axID, int32 iChan, boolean bOn);
	virtual boolean UserOutputGet(int32 axID, int32 iChan, boolean *pOn);
	virtual boolean UserInput(int32 axID, int32 iChan, boolean *pOn);
	/* Input */
	boolean IsInput(dword dwChan);
	boolean Input32(dword *pIn);
	boolean Input32Ex(dword modID, dword *pIn);

	/* Output */
	boolean IsOutput(dword dwChan);
	boolean IsOutput32(dword *pOut);
	boolean IsOutput32Ex(dword modID, dword *pOut);
	boolean Output(dword dwChan, boolean bOn);
	boolean Output32(dword dwOut);
	boolean Output32Ex(dword modID, dword dwOut);

	// LoadRate
	virtual boolean LoadRateGet(int32 axID, int32 *iRate);

	// Trigger
	virtual boolean TrigEnable(int32 axID, boolean bEnable);
	virtual boolean TrigStart(int32 axID); // AXT Only
	virtual boolean TrigStop(int32 axID);  // AXT Only
	virtual boolean TrigSetTable(int32 axID, double64 dStart, double64 dEnd, double64 dInterval);
	virtual boolean TrigInvert(int32 axID, boolean bEnable);	// UMAC Only

	// EMO
	virtual boolean IsEMO(dword emoPos);

	// Path Moving
	virtual boolean IsPathMoving(void);

	// Encoder
	virtual boolean EncInvert(int32 axID, boolean bEnable);	

	// E-GEAR
	virtual boolean EgearSet(int32 axMaster, int32 axSlave, double64 ratio);
	virtual boolean EgearIsSet(int32 axID);

	boolean HOMEset(int32 axID, double64 Hoffset);
	boolean HOMEget(int32 axID, double64 *Hoffset);

protected:
	virtual boolean DEVTBL_INITPARAM(motdev_axis_s *ax);
	virtual dword HOMEPROC(MOTHOMEItem_s *pItem);

	dword HOMEPROC_GEN(MOTHOMEItem_s *pItem);  // General Homing Routine
	dword HOMEPROC_PLMT(MOTHOMEItem_s *pItem);
	dword HOMEPROC_ROTATE(MOTHOMEItem_s *pItem);

	dword HOMEPROC_CQIHAL(MOTHOMEItem_s *pItem);  //Homing Routine
	boolean CQIHAL_Home(int32 axID);
	boolean CQIHAL_HomeStop(int32 axID);
public:
	boolean CQIHAL_IsHomeDone(int32 axID, boolean *pDone);

};

#endif /* _MOTMod_H_ */


/*--- END OF MOTFTbl.H ---*/
